﻿using System.Windows;
using System.Windows.Input;

namespace Player
{
    public partial class ProgressSlider
    {
        public static readonly DependencyProperty PointerLocationProperty;

        static ProgressSlider()
        {
            PointerLocationProperty = DependencyProperty.Register("PointerLocation", typeof(double), typeof(ProgressSlider));
        }

        public ProgressSlider()
        {
            InitializeComponent();
        }

        public double PointerLocation
        {
            get
            {
                return (double)GetValue(PointerLocationProperty);
            }

            set
            {
                SetValue(PointerLocationProperty, value);
            }
        }

        private void UserControl_MouseMove(object sender, MouseEventArgs e)
        {
            Point position = e.GetPosition(this);
            PointerLocation = position.X / ActualWidth;
        }

        private void UserControl_MouseEnter(object sender, MouseEventArgs e)
        {
            Pointer.Visibility = Visibility.Visible;
        }

        private void UserControl_MouseLeave(object sender, MouseEventArgs e)
        {
            Pointer.Visibility = Visibility.Hidden;
        }
    }
}

